package com.smc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.smc.mapper.UserMapper;
import com.smc.model.User;
import com.smc.dao.UserDao;

import java.util.List;
import java.util.Map;

@Service
public class UserDaoImpl implements UserDao {
    @Autowired
    private UserMapper userMapper;
    @Override
    public void insert(User user) {
         userMapper.insert(user);
    }

    @Override
    public void update(User user) {
        userMapper.update(user);
     }

    @Override
    public void delete(String id) {
        userMapper.delete(id);
    }

    @Override
    public PageInfo selectPage(int start, int rownum, Map<String,String> map) {
        PageHelper.startPage(start,rownum);
        List<User> list=userMapper.selectPage(map);
        PageInfo pageInfo=new PageInfo<User>(list);
        PageHelper.clearPage();
        return pageInfo;
    }

    @Override
    public User getUser(String id) {
         return userMapper.getUser(id);
    }
}
